package com.weharvest.edu.service;

import com.weharvest.edu.entity.BackstageRole;
import com.weharvest.edu.utlis.page.SimplePage;
import org.hibernate.service.spi.ServiceException;

import java.util.List;
import java.util.Map;

/**
 * 基本CRUD
 */
public  interface BaseService  {


    /**
     * 带参数
     * @param params
     * @return
     */
    public <ModelType> List<ModelType> findByParams(Map<String,Object>params);


    /**
     * 实体类+带参数
     * @param modelType
     * @param <ModelType>
     * @return
     */
    public <ModelType> List<ModelType> findByMp(ModelType modelType,Map<String,Object>params);



    /**
     * 增加记录
     * @param modelType
     * @param <ModelType>
     * @return
     * @throws ServiceException
     */
    public <ModelType> int add(ModelType modelType) throws ServiceException;

    /**
     * 新增记并返回主键
     *
     * @param modelType
     * @return
     * @throws ServiceException
     */
    public <ModelType> int addResultPrimary(ModelType modelType)
            throws ServiceException;

    /**
     * 根据主键查
     *
     * @param modelType
     * @return
     * @throws ServiceException
     */
    public <ModelType> ModelType findById(ModelType modelType)
            throws ServiceException;

    /**
     * 根据参数查询
     *
     * @param modelType 返回类型
     * @param params    页面其他参数
     * @return
     * @throws ServiceException
     */
    public <ModelType> List<ModelType> findByParam(ModelType modelType,
                                                 Map<String, Object> params) throws ServiceException;


    /**
     * 批量查询
     *
     * @param primary
     * @param <ModelType>
     * @return
     * @throws ServiceException
     */
    public <ModelType> List<ModelType> findByBatch(
            List<String> primary) throws ServiceException;



    /**
     * 根据modelType修改实体
     *
     * @param modelType
     * @return
     * @throws ServiceException
     */
    public <ModelType> int modifyById(ModelType modelType)
            throws ServiceException;

    /**
     * 根据自定义参数修改
     */
    public <ModelType> int modifyByParams(Map<String, Object> whereParams,
                                          Map<String, Object> setParams) throws ServiceException;

    /**
     * 根据条件查数量
     *
     * @param params
     * @return
     * @throws ServiceException
     */
    public int findCount(Map<String, Object> params) throws ServiceException;


//    /**
//     * 批量查询根据主键，带分页
//     *
//     * @param page
//     * @param likeField
//     * @param orderByField
//     * @param orderBy
//     * @param params
//     * @param primary
//     * @return
//     * @throws DaoException
//     */
//    public <ModelType> List<ModelType> batchFindCourseListByPrimaryAndPage(
//            SimplePage page, Map<String, Object> likeField,
//            String orderByField, String orderBy, Map<String, Object> params,
//            List<String> primary) throws DaoException;


//    /**
//     * 根据参数查询列表
//     *
//     * @param page
//     * @param orderByField
//     * @param orderBy
//     * @param params
//     * @return
//     * @throws ServiceException
//     */
//    public <ModelType> List<ModelType> findByPage(SimplePage simplePage,
//                                                  String orderByField, String orderBy, Map<String, Object> params)
//            throws ServiceException;

//    /**
//     * 根据参数查询列表 +模糊查询
//     *
//     * @param page
//     * @param orderByField
//     * @param orderBy
//     * @param params
//     * @return
//     * @throws ServiceException
//     */
//    public <ModelType> List<ModelType> findByPageAndLimit(
//            SimplePage simplePage, Map<String, Object> likeField,
//            String orderByField, String orderBy, Map<String, Object> params)
//            throws ServiceException;

//    /**
//     * 公共的保存操作
//     *
//     * @param params key:增、删、改操作枚举 value:对象列表
//     * @return 影响条数
//     * @throws ServiceException
//     */
//    public <ModelType> int save(Map<CommonOperatorEnum, List<ModelType>> params)
//            throws ServiceException;
//
//    // 用户分页查询次数
//    public int findCountByLimit(Map<String, Object> params,
//                                Map<String, Object> limitParams) throws ServiceException;

}
